package com.zhongzhi.nn.push.run;

import java.io.UnsupportedEncodingException;
import java.util.Timer;
import java.util.TimerTask;

import com.zhongzhi.nn.push.configure.ApplicationConstants;
import com.zhongzhi.nn.push.server.PushNoticeInfo;
import com.zhongzhi.nn.push.server.PushProjectInfo;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class Run {
	
	//1个小时的毫秒 ，1小时推一次,从配置文件中获取时间间隔
	private static Long OneDay_Millisecond = ApplicationConstants.time;

	public static Log log = LogFactory.getLog(Run.class);

	public static void main(String [] s) {
		/*System.out.println("服务正在启动！请等待。。。。");
		Run run = new Run();
		run.startPushSchedule();
		System.out.println("服务启动成功！");*/
			TimerTask task = new TimerTask() {
				@Override
				public void run() {
					PushProjectInfo info = new PushProjectInfo();
					PushNoticeInfo noticeInfo = new PushNoticeInfo();
					try {
					log.info("==========开始推送==========");
					String s1 = info.push();
					log.info("项目备案："+s1);
					String s2 = noticeInfo.pushNotice();
					log.info("项目招标："+s2);
					String s3 = noticeInfo.pushChangeNotice();
					log.info("项目变更："+s3);
					String s4 = s4 = noticeInfo.pushZBNotice();
             		log.info("项目中标："+s4);
             		log.info("==========推送结束==========");
					} catch (UnsupportedEncodingException e) {
						e.printStackTrace();
					}

				}
			};

			Timer timer =new Timer();
		    long delay = 0;
		    timer.scheduleAtFixedRate(task,delay,OneDay_Millisecond);
	}


}
